﻿using IntelligentAgriculture.Contracts.Dto.Output.EarTagOutput;
using IntelligentAgriculture.Contracts.Dto.Output.RidgepOutPut;
using IntelligentAgriculture.Contracts.Interface.Iridgepletype;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using IntelligentAgriculture.WebAPI.Application.Command.RidgepCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.RidgepCommandHandler
{
    public class RidgepFindCommandHandler : IRequestHandler<RidgepFindCommand, Results<RidgepShowOutput>>
    {
        private readonly IridegpoleService _ridegpoleService;
        public RidgepFindCommandHandler(IridegpoleService ridegpoleService)
        {
            _ridegpoleService = ridegpoleService;
        }
        /// <summary>
        /// 处理 RidgepFindCommand 命令的方法
        /// </summary>
        /// <param name="request">包含要查找的id参数的请求对象</param>
        /// <param name="cancellationToken">用于取消操作的取消令牌</param>
        /// <returns>异步返回包含 RidgepShowOutput 结果的任务</returns>
        public async Task<Results<RidgepShowOutput>> Handle(RidgepFindCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _ridegpoleService.Find(request.id);
                return Results<RidgepShowOutput>.DataResult(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
